package lims.cloud.system.base.mybatis;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lims.cloud.system.department.Department;
import org.springframework.web.bind.annotation.*;

import java.util.List;

public interface IBaseController<T> {

    @GetMapping("/getOneByCondition/{columnName}/{columnValue}")
    Result<T> getOneByCondition(@PathVariable("columnName") String columnName, @PathVariable("columnValue") Object columnValue);


    @GetMapping("/getListByCondition/{columnName}/{columnValue}")
    Result<List<T>> getListByCondition(@PathVariable("columnName") String columnName, @PathVariable("columnValue") Object columnValue);

    @PostMapping("/getOneByConditions")
    Result<T> getOneByConditions(T conditions);


    @PostMapping("/getListByConditions")
    Result<List<T>> getListByConditions(T conditions);

    @PostMapping("/getListByConditionsWithPage")
    Result<IPage<T>> getListByConditionsWithPage(T conditions);

    @PostMapping
    Result<T> insertOne(T entity);

    @PutMapping
    Result<T> updateOne(T entity);

    //    @PreAuthorize("hasRole('超级管理员')")
    @DeleteMapping("/physical/{id}")
    Result<?> physicalDeleteById(@PathVariable("id") Long id);

    @DeleteMapping("/logical/{id}")
    Result<?> logicalDeleteById(@PathVariable("id") Long id);

    //激活，将deleted变为0
    @GetMapping("/active/{id}")
    Result<?> activeById(@PathVariable("id") Long id);

    @DeleteMapping("/deleteByKeyValue/{key}/{value}")
    Result<?> deleteByKeyValue(@PathVariable String key, @PathVariable Object value);

    @GetMapping("/tree")
    Result<List<Department>> getTree();
}
